#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QResizeEvent>
#include <QPaintEvent>
#include <QMouseEvent>
#include <QDir>

#include <bottomwidget.h>
#include <https.h>
#include <listwidget.h>
#include <titlebar.h>
#include <albumtopwidget.h>
#include <albumwidget.h>
#include <localmusicwidget.h>
#include <loginwidget.h>
#include <historymusicwidget.h>
#include <searchmusicwidget.h>
#include <createnewalbum.h>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void SetCurrentWidget(AlbumWidget*w);

signals:
    void albumName(const QStringList&albumname);
    void albumId(const QVector<qint64>&albumid);
protected:
    void resizeEvent(QResizeEvent *event) override;
    void paintEvent(QPaintEvent*e)override;
    void mousePressEvent(QMouseEvent*e)override;
private slots:
    void onLoginRequest(const QString&userid,const QString&password);
    void onLoginResponse(const QJsonObject&obj);
    void onSearchRequest(const QString&text);
    void onSearchResponse(const QJsonObject&obj);
    void onNewMainWindow(const QSize& newsize);
    void onDeleteSongItem(qint64 albumid,qint64 songid);
    void onFavorSong(qint64 songid);
    void onItemClicked(QListWidgetItem*item);
    void onLocalMusicShow();
    void onMyLikeShow();
    void onRecommendShow();
    void onHistoryShow();
    void onFlush();
    void onCreateNewAlbum();
    void onClickListWidgetButton(qint32 order);
    void onDownload(const QVector<SongItem*>&songitems);
    //void onTimerTimeOut(){loginw->show();timer->stop();}

private:
    Ui::MainWindow *ui;

    //QTimer*timer;
    Https*https;
    ListWidget *listw;
    TitleBar*title;
    BottomWidget*bottomw;
    CreateNewAlbum*createnew;
    PopupListWidget*poplistw;
    qint64 userid;
    qint64 tmp=0;

    QVector<AlbumWidget*>albums;
    AlbumWidget*currentw;
    AlbumWidget*recommendw;
    LoginWidget*loginw;
    AlbumWidget*mylikew;
    LocalMusicWidget *localmusicw;
    HistoryMusicWidget*historymusicw;
    SearchMusicWidget*searchmusicw;

    bool on;
};
#endif // MAINWINDOW_H
